<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <div style="width: 290px;background: #5DA9EF;font-size: 10px;border-radius: 8px;box-shadow: 0px 0px 5px 0px;">
                <form class="layui-form">
                    <div class="layui-form-item" style="padding-top: 5px;margin-bottom: 5px;">
                        <label class="layui-form-label" style="width: 53px;"><span class="x-red">*</span>开始日期</label>
                        <div class="layui-input-inline" style="width: 120px;">
                            <input class="layui-input" type="text" name="start" lay-verify="start" placeholder="本次授课日期" id="LAY_demorange_s">
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-bottom: 5px;">
                        <label class="layui-form-label" style="width: 53px;"><span class="x-red">*</span>授课课时</label>
                        <div class="layui-input-inline" style="width: 120px;">
                            <select name="sk_num">
                                <option value="1">1课时</option>
                                <option value="2">2课时</option>
                                <option value="3">3课时</option>
                            </select>
                        </div>
                        <!-- <div class="layui-form-mid layui-word-aux">本次授课课时数</div> -->
                    </div>
                    <div class="layui-form-item" style="margin-bottom: 5px;">
                        <label class="layui-form-label" style="width: 53px;"><span class="x-red">*</span>授课总结</label>
                        <div class="layui-input-inline">
                            <textarea name="zongjie" lay-verify="zongjie" cols="28" rows="5" placeholder="请老师用不超过100的文字对本次授课作出总结" style="width: 100%;"></textarea> 
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <input type="hidden" name="kec_id" value="{$id}">
                        <button  class="layui-btn" lay-filter="add" lay-submit="">授课签到</button>
                    </div>
                </form>
            </div>
            <div style="width: 200px;background: #F8F8F8;position: absolute;right: 20px;top: 60px;font-size: 10px;box-shadow: 0px 0px 5px 0px;">
                <p style="font-weight: bold;text-align: center;">上次授课签到信息</p>
                <p style="padding-left: 24px;">授课时间：{$shouk_zj.date}</p>
                <p style="padding-left: 24px;">课时数量：{$shouk_zj.keshi}课时</p>
                <p style="padding-left: 24px;">家长评论：<textarea cols="25" rows="4" placeholder="未评论" disabled="" style="width: 98%;">{$shouk_zj.zongjie}</textarea></p>

                <p style="padding-left: 24px;">家长状态：
                <?php if ($shouk_zj['jz_qd'] == 1) { ?>
                    <span class="layui-btn">已签到</span>
                <?php }else { ?>
                    <span class="layui-btn" style="background: #FF6000;">未签到</span>
                <?php } ?>
                </p>
            </div>

            <span>授课签到表:</span>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>授课时间</th>
                        <th>课时</th>
                        <th>老师总结</th>
                        <th>家长评论</th>
                        <th>家长签到</th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($signs as $v) { ?>
                    <tr>
                        <td>
                            {$v.id}
                        </td>
                        <td style="font-size: 8px;">
                            <?php echo date('Y-m-d H:i',$v['addtime']) ?>
                        </td>
                        <td>
                            {$v.keshi}
                        </td>
                        <td style="padding: 1px 1px;">
                           <textarea cols="15" rows="3" placeholder="未评论" disabled="">{$v.zongjie}</textarea>
                        </td>
                        <td style="padding: 1px 1px;">
                            <textarea cols="15" rows="3" placeholder="未评论" disabled="">{$v.comment}</textarea>
                        </td>
                        <td style="font-size: 8px;">
                        <?php if ($v['jz_qd'] == 1) { ?>
                            <span style="padding: 5px;background: #099793;color: #fff;border-radius: 2px;">已签到</span>
                        <?php }else { ?>
                            <span style="padding: 5px;background: #FF6000;color: #fff;border-radius: 2px;">未签到</span>
                            <a title="短信通知" href="javascript:;" onclick="jz_tongz(this,'{$v.id}')">通知</a>
                        <?php } ?>
                        </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>

        </div>
        <script src="__PUBLIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="__PUBLIC__/admin/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['form','layer','laydate'], function(){
                $ = layui.jquery;
                laydate = layui.laydate;//日期插件
              var form = layui.form()
              ,layer = layui.layer;


              var start = {
                min: '2017-01-01 23:59:59'
                ,max: '2099-06-16 23:59:59'
                ,istoday: false
                ,choose: function(datas){
                  end.min = datas; //开始日选好后，重置结束日的最小日期
                  end.start = datas //将结束日的初始值设定为开始日
                }
              };
              document.getElementById('LAY_demorange_s').onclick = function(){
                start.elem = this;
                laydate(start);
              }

              //自定义验证规则
              form.verify({
                start: function(value){
                  if(value.length < 1){
                    return '请选择本次授课日期';
                  }
                }
                ,zongjie: function(value){
                  if(value.length < 1){
                    return '请老师用不超过100的文字对本次授课作出总结';
                  }
                }
              });

              //监听提交
              form.on('submit(add)', function(data){
                //console.log(data);
                //发异步，把数据提交给php
                $.ajax({
                    url: "{:U('laoshi/qiandaozj')}",//请求地址
                    type: "post",//请求方式
                    dataType: "json",//返回数据类型
                    data: data.field,//发送的参数
                    })
                    .done(function(response) {
                          if(response.error==0){
                             layer.msg(response.info ,{icon:5});

                          }else{
                             layer.msg(response.info ,{icon:6});
                             location.reload();
                            // layer.alert(response.info, {icon: 6},function () {
                            //     // 获得frame索引
                            //     var index = parent.layer.getFrameIndex(window.name);
                            //     //关闭当前frame
                            //     parent.layer.close(index);
                            //     parent.location.reload();
                            // });
                          }
                      })
                    .fail(function() {
                        alert("ajxs交互失败");
                    })  

                return false;
              });
                           
            });

            /*通知*/
            function jz_tongz(obj,id){
                layer.confirm('确认要发短信通知吗？',function(index){
                    //发异步删除数据
                    id = id;
                    $.ajax({
                        url: "{:U('laoshi/tongzjz')}",//请求地址
                        type: "post",//请求方式
                        dataType: "json",//返回数据类型
                        data: {id:id},//发送的参数
                        })
                        .done(function(response) {
                              if(response.error==1){
                                layer.msg(response.info ,{icon:6});
                              }else{
                                layer.msg(response.info ,{icon:5});
                              }
                          })
                        .fail(function() {
                            alert("ajxs交互失败");
                        })  
                    return false;
                });
            }
        </script>
    </body>

</html>